update.js ➔ ???   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 32
rs 8.8571
nop 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A update.js ➔ ... ➔ server.post.validation.options.errorResponder 0 4 1
1
'use strict'
2
3
import Joi from 'joi'
4
import passport from 'passport'
5
import { passwords } from '../../controllers'
6
7
export default function (server) {
8
  server.post({
9
    name: 'password//changed',
10
    path: '/password_changed',
11
    validation: {
12
      schema: {
13
        body: Joi.object({
14
          password: Joi.string()
15
            .min(6)
16
            .max(15)
17
            .required(),
18
          password_confirmation: Joi.any()
19
            .valid(Joi.ref('password'))
20
            .required()
21
        }).required()
22
      },
23
      options: {
24
        joiOptions: {
25
          allowUnknown: true
26
        },
27
        errorResponder (transformedErr, req, res, next) {
28
          req.ifError = transformedErr
29
          return next()
30
        }
31
      }
32
    }
33
  },
34
  passport.authenticate('jwtBodyFieldStrategy', {
35
    session: false
36
  }),
37
  passwords.update) // change password
38
}
39